package com.enterprise.struts2.news;

import com.enterprise.daoImpl.NewsDaoImpl;
import com.enterprise.domain.News;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


public class NewsAction extends ActionSupport implements ModelDriven<News>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private News news=new News();
	
	public News getNews() {
		return news;
	}

	public void setNews(News news) {
		this.news = news;
	}

	@Override
	public News getModel() {
		// TODO Auto-generated method stub
		return news;
	}
	NewsDaoImpl daoImpl=new NewsDaoImpl();
	public String add(){
		if(daoImpl.addNews(news)>0)
		return "success";
		else {
			this.addActionError("添加新闻出错");
			return "input";
		}
	}
	
	public String update(){
		if(daoImpl.updateNews(news)>0)
			return "success";
			else {
				this.addActionError("更新新闻出错");
				return "input";
			}
	}
	
	public String delete(){
		
		
		if(daoImpl.deleteNews(news)>0)
			return "success";
			else {
				this.addActionError("删除新闻出错");
				return "input";
			}
	}
	

	
	
}
